﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using DepartmentWork.Model
@model DepartmentWork.Model.ProjectManagementViewModel

<link href="~/Assets/plugins/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-select/bootstrap-select.min.js"></script>
<link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
<link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
<script src="~/Assets/js/pages/form-elements.js"></script>
<style>
   ul>.active {
       font-weight:bold
   }
      #table_CreateProject td {
       padding-left: 5px;
       padding-top: 5px
   }

</style>
<script>
    window.onload = function ()
    {
        
        $("#datetimepicker").datepicker({
            autoclose: true,
            pickerPosition: "bottom-right"
        });
        $("#datetimepicker2").datepicker({
            autoclose: true,
            pickerPosition: "bottom-right"
        });
    };
    
    

</script>

<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index","Home",new{area=""})"><i class="icon fa fa-home"></i>主页</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>项目管理</a></li>
        </ol>
    </div>
</div>

@{
    if (ViewBag.CreateProjectFlag == "CreateTrue")
    {
      <div class="alert alert-success">
	    <button type="button" class="close" data-dismiss="alert">×</button>
	    <strong>&emsp;项目添加成功！</strong> 
      </div>
    }
    if (ViewBag.CreateProjectFlag == "CreateFalse")
    {
      <div class="alert alert-danger">
	    <button type="button" class="close" data-dismiss="alert">×</button>
	    <strong>&emsp;项目添加失败！</strong> @ViewBag.Info
    </div>
    }
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span class="break"></span>项目列表</h6>
                  @{
                      if (ViewBag.IsAdmin == true)
                    {
                        <div class="panel-actions">
                            <a data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;新增项目&nbsp;&nbsp;</a>
                        </div>
                    }
                }

            </div>
            <div class="panel-body">
                <div class="tabs">
                    <ul class="nav nav-tabs">
                        <li class="active" >
                            <a style="color:black" href="#overview"  data-toggle="tab">未完成</a>
                        </li>
                        <li >
                            <a style="color:black" href="#edit" data-toggle="tab">已完成</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="overview" class="tab-pane active">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover" style="text-align: center">
                                        <thead >
                                            <tr>
                                                <th style="width:15%;text-align: left">编号
                                                </th>
                                                <th style="width:40%;text-align: left">项目名称</th>
                                                <th style="width:20%;text-align: left">项目负责人</th>
                                                <th style="width:15%;text-align: left">项目创建日期</th>
                                                 <th style="width:10%;text-align: left">工作记录操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @{
                                                if (this.Model.ExecuteProjectList.Tables[0].Rows.Count != 0)
                                                {
                                                    for (int i = 0; i < this.Model.ExecuteProjectList.Tables[0].Rows.Count; i++)
                                                    {
                                                        var item = this.Model.ExecuteProjectList.Tables[0].Rows[i];
                                                        <tr>
                                                            <td style="color:black;text-align: left">@item["PROJECT_MANAGEMENT_NO"]
                                                            </td>
                                                            <td style="color:cornflowerblue;text-align: left"><a style="color:cornflowerblue" href="@Url.Action("ProjectInfo", "Project", new { area = "ProjectManageArea", projectId = item["PROJECT_MANAGEMENT_ID"].ToString() })">@Html.SubString(item["PROJECT_MANAGEMENT_TITLE"].ToString())</a></td>
                                                            <td style="color:black;text-align: left">@Html.SubString(item["PROJECT_MANAGEMENT_LEADER"].ToString())</td>
                                                            <td style="color:black;text-align: left">@Convert.ToDateTime(item["PROJECT_MANAGEMENT_CREATETIME"]).ToString("yyyy-MM-dd")</td>
                                                            <td style="text-align: left">
                                                                @{
                                                                    if (ViewBag.IsAdmin == true)
                                                                    {
                                                                       <a data-toggle="modal" onclick="ShowCreateProjectWorkReocred('@item["PROJECT_MANAGEMENT_ID"]')" style="color:cornflowerblue;cursor: pointer" data-target="#div_CreateProjectWorkReocred">新增</a>
                                                                        @:&emsp; 
                                                                    }
                                                                }
                                                                
                                                                <a  href="@Url.Action("Index", "WorkReocred", new { area = "ProjectManageArea", projectId = item["PROJECT_MANAGEMENT_ID"] })" style="color:cornflowerblue;cursor: pointer" > 查询</a>
                                                            </td>
                                                        </tr>
                                                    }
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                    @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalExecute"])
                                </div>
                            </div>
                        </div>
                        <div id="edit" class="tab-pane updateProfile">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover" style="text-align: center">
                                        <thead>
                                            <tr>
                                                <th style="width:15%;text-align: left">编号
                                                </th>
                                                <th style="width:40%;text-align: left">项目名称</th>
                                                <th style="width:20%;text-align: left">项目负责人</th>
                                                <th style="width:15%;text-align: left">项目创建日期</th>
                                                <th style="width:10%;text-align: left">工作记录操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @{
                                                if (this.Model.FinishProjectList.Tables[0].Rows.Count != 0)
                                                {
                                                    for (int i = 0; i < this.Model.FinishProjectList.Tables[0].Rows.Count; i++)
                                                    {
                                                        var item = this.Model.FinishProjectList.Tables[0].Rows[i];
                                                        <tr>
                                                            <td style="color:black;text-align: left">@item["PROJECT_MANAGEMENT_NO"]
                                                            </td>
                                                            <td style="color:cornflowerblue;text-align: left"><a style="color:cornflowerblue" href="@Url.Action("ProjectInfo", "Project", new { area = "ProjectManageArea", projectId = item["PROJECT_MANAGEMENT_ID"].ToString() })">@Html.SubString(item["PROJECT_MANAGEMENT_TITLE"].ToString())</a></td>
                                                            <td style="color:black;text-align: left">@Html.SubString(item["PROJECT_MANAGEMENT_LEADER"].ToString())</td>
                                                            <td style="color:black;text-align: left">@Convert.ToDateTime(item["PROJECT_MANAGEMENT_CREATETIME"]).ToString("yyyy-MM-dd")</td>
                                                            <td style="text-align: left">
                                                                <a  href="@Url.Action("Index", "WorkReocred", new { area = "ProjectManageArea", projectId = item["PROJECT_MANAGEMENT_ID"] })" style="color:cornflowerblue;cursor: pointer" > 查询</a>
                                                            </td>
                                                        </tr>
                                                    }
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                     @Html.ShowPageNavigate((int)ViewData["pageIndexFinish"], (int)ViewData["pageSizeFinish"], (int)ViewData["totalFinish"])
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- 模态框（Modal） -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">


    <script>


        function Create()
        {
            
            var message = "";
            if ($("#tb_ProjectName").val().length>30)
            {
                message += " · 项目名称不能超过30字符" + "<br/>";
            }

            if ($("#tb_ProjectName").val() == "" || $.trim($("#tb_ProjectName").val()) == "") {
                message += " · 项目名称不能为空" + "<br/>";
            }

            if ($("#tb_ProjectDescription").val() == "") {
                message += " · 项目描述不能为空" + "<br/>";
            }
            if ($("#tb_ProjectLeader").val() == "" || $.trim($("#tb_ProjectLeader").val()) == "") {
                message += " · 负责人不能为空" + "<br/>";
            } 
            if ($("#tb_DeadTime").val() == "")
            {
                message += " · 完成日期不能为空" + "<br/>";
            }
            if ($("#select_BusinessType").val() == "" )
            {
                message += " · 业务类型不能为空" + "<br/>";
            }
            if (message != "") {
                $("#lb_CheckCreateProjectMessage").html(message);
                $("#div_CheckCreateProjectMessage").css("display", "block");
                return false;
            }
            else {
                $("#lb_CheckCreateProjectMessage").html("");
                $("#div_CheckCreateProjectMessage").css("display", "none");
                $("#frm_CreateProject").submit();
            }
        }



    </script>

    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }
    </style>
    <div class="modal-dialog"style="width: 650px;">
        <div class="modal-content">
            <form id="frm_CreateProject" action="@Url.Action("CreateProject", "Project", new { area = "ProjectManageArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">新增项目
                    </h4>
                </div>
                <div id="div_CreateProject" class="modal-body">

                    <div class="alert alert-danger" id="div_CheckCreateProjectMessage" style="display: none">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>
                            <label id="lb_CheckCreateProjectMessage"></label>
                        </strong>
                    </div>

                    <table id="table_CreateProject">
                        <tr>
                            <td >项目名称:</td>
                            <td colspan="3">
                             <input id="tb_ProjectName" style="border-color: cornflowerblue" name="tb_ProjectName" class="form-control" placeholder="Text" type="text">
                            </td>
                        </tr>
                        <tr>
                            <td>负责人：</td>
                            <td>
                                 <select style="margin-left: -100px"   name="tb_ProjectLeader" id="tb_ProjectLeader" class="form-control selectpicker" multiple="multiple">
                                @{
                                    List<UserInfoViewModel> userList = (List<UserInfoViewModel>)TempData["UserList"];
                                    if (userList != null)
                                    {
                                        for (int i = 0; i < userList.Count(); i++)
                                        {
                                            var item = userList[i];
                                            <option value="@item.UserName">@item.UserName</option>
                                        }
                                    }
                                    
                                }
                            </select>
                            </td>
                            <td>预计完成日期：</td>
                            <td>
                                <div class="col-md-9" style="padding-top: 10px">
                                <div class="input-append date" id="datetimepicker" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                    <input id="tb_DeadTime" name="tb_DeadTime" style="border-color: cornflowerblue" class="form-control" size="16" type="text" value="">
                                    <span class="add-on"><i class="icon-th"></i></span>
                                </div>
                            </div>
                            </td>
                        </tr>
                        <tr>
                            <td>业务联系人：</td>
                            <td>
                                 <input id="text-input" name="tb_BusinessUser" class="form-control" placeholder="Text" type="text">
                            </td>
                            <td>业务主管部门：</td>
                            <td>
                              <input id="text-input" name="tb_BusinessDepartment" class="form-control" placeholder="Text" type="text">
                            </td>
                        </tr>
                        <tr>
                            <td>业务联系人电话：</td>
                            <td>
                                 <input id="text-input" name="tb_BusinessUserTel" class="form-control" placeholder="Text" type="text">
                            </td>
                            <td>业务类型：</td>
                            <td>
                                <select id="select_BusinessType" name="select_BusinessType" class="form-control select2-active">
                                <option value="">请选择</option>
                                <option value="办公">办公</option>
                                <option value="政法">政法</option>
                                <option value="关税">关税</option>
                                <option value="监管">监管</option>
                                <option value="加贸">加贸</option>
                                <option value="行邮">行邮</option>
                                <option value="统计">统计</option>
                                <option value="稽查">稽查</option>
                                <option value="缉私">缉私</option>
                                <option value="财务">财务</option>
                                <option value="人教">人教</option>
                                <option value="监察">监察</option>
                                <option value="关保">关保</option>
                                <option value="政工">政工</option>
                                <option value="督审">督审</option>
                                <option value="科技">科技</option>
                                <option value="其他">其他</option>
                            </select>
                            </td>
                        </tr>
                          <tr>
                            <td > 功能描述：</td>
                            <td colspan="3">
                                 <textarea id="tb_DevelopDescription" name="tb_ProjectDescription" rows="5" class="form-control" placeholder="Content.."></textarea>
                            </td>
                        </tr>
                    </table>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="button" onclick="Create()" value="新增" class="btn btn-primary" />
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>



<!-- 模态框（Modal） -->

<div class="modal fade" id="div_CreateProjectWorkReocred" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    

    <script>

        function ShowCreateProjectWorkReocred(projectId) {
            $("#hid_ProjectId").val(projectId);
        }

        function SubmitCreate()
        {

            var message = "";
            if ($("#tb_ProjectWorkReocredTitle").val() == "" || $.trim($("#tb_ProjectWorkReocredTitle").val()) == "")
            {
                message += " · 工作记录标题不能为空" + "<br/>";
            }
            if ($("#tb_ProjectWorkReocredDescription").val() == "")
            {
                message += " · 工作记录内容不能为空" + "<br/>";
            }
            if (message != "")
            {
                $("#lb_CheckCreateWorkReocredMessage").html(message);
                $("#div_CheckCreateWorkReocredMessage").css("display", "block");
                return false;
            }
            else
            {
                $("#lb_CheckCreateWorkReocredMessage").html("");
                $("#div_CheckCreateWorkReocredMessage").css("display", "none");
                $("#frm_CreateProjectWorkReocred").submit();
            }
        }

    </script>

    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }
    </style>
    <div class="modal-dialog">
        <div class="modal-content">
            <form id="frm_CreateProjectWorkReocred" action="@Url.Action("CreateWorkReocred", "WorkReocred", new { area = "ProjectManageArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">新增工作记录
                    </h4>
                </div>
                <div id="div_CreateProject" class="modal-body">
                    <div class="alert alert-danger" id="div_CheckCreateWorkReocredMessage" style="display: none">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>
                            <label id="lb_CheckCreateWorkReocredMessage"></label>
                        </strong>
                    </div>

                    <div class="row">
                        <input type="hidden" id="hid_ProjectId" name="hid_ProjectId" />
                        <label class="col-md-3 control-label" for="text-input">记录主题</label>
                        <div class="col-md-9">
                            <input id="tb_ProjectWorkReocredTitle" style="border-color: cornflowerblue"
                                   name="tb_ProjectWorkReocredTitle" class="form-control" placeholder="Text"
                                   type="text">
                            <span class="span_ProjectWorkReocredTitle"></span>
                        </div>
                    </div>
                    <br />


                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">描述：</label>
                        <div class="col-md-9">
                            <textarea id="tb_ProjectWorkReocredDescription" name="tb_ProjectWorkReocredDescription" rows="5" class="form-control" placeholder="Content.."></textarea>
                        </div>
                    </div>

                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label">发生日期：</label>
                        <div class="col-md-9">
                            <div class="input-append date" id="datetimepicker2" data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input name="tb_ExecuteTime" style="border-color: cornflowerblue" class="form-control" size="16" type="text" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                            <span class="span_DevelopDescription"></span>
                        </div>
                    </div>

                    <br />


                    <div class="row">
                        <br />
                        <label class="col-md-3 control-label">工作记录级别：</label>
                        <div class="col-md-9">

                            <select name="select_ProjectWorkReocredLevel" class="form-control select2">
                                <option value="0">普通</option>
                                <option value="1">重要</option>
                            </select>
                        </div>
                    </div>

                    <br />

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="button" onclick="SubmitCreate()" value="新增" class="btn btn-primary" />
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

